{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "cf4c860c",
   "metadata": {},
   "source": [
    "## 元组(tuple)\n",
    "* [元组]()\n",
    "> 1.它是和list几乎完全一样的序列数据\n",
    "> 2.它与list不同的地方是，**不可变** （因为不可变，所以几乎没有方法）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "65f8880f",
   "metadata": {},
   "outputs": [],
   "source": [
    "import time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "7f3a8947",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "time.struct_time(tm_year=2021, tm_mon=10, tm_mday=25, tm_hour=11, tm_min=30, tm_sec=48, tm_wday=0, tm_yday=298, tm_isdst=0)"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.localtime()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "b82559d7",
   "metadata": {},
   "outputs": [],
   "source": [
    "names = \"lala\",\"huhu\",\"lili\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "1594aac8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "('lala', 'huhu', 'lili')"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "56cb5583",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tuple"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(names)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "1374cf1d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names.count(\"lala\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "170da9db",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names.index(\"lala\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a2403bed",
   "metadata": {},
   "source": [
    "# 字典\n",
    "> 1.字典的创建方式\n",
    ">>1.直接创建字典，按照字典的结构：[]\n",
    "\n",
    "\n",
    ">>字典：映射\n",
    "\n",
    ">>>特性：dict是无序的  key 是唯一的  key 不可变性"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "e767ca1e",
   "metadata": {},
   "outputs": [],
   "source": [
    "stu_info = {\n",
    "    \"stu10001\":\"alex\",\n",
    "    \"stu10002\":\"jack\",\n",
    "    \"stu10003\":\"marry\"\n",
    "}\n",
    "stu10001 = {\n",
    "     \"name\":\"alex\",\n",
    "     \"age\":\"18\",\n",
    "     \"job\":\"student\"\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "0fb2fd5f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'stu10001': 'alex', 'stu10002': 'jack', 'stu10003': 'marry'}"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stu_info"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "99860ddd",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 第二种字典创建方法 \n",
    "# 与第一种的区别：\n",
    "#        1.dict()  vs  {}\n",
    "#        2. stu10001 vs\"stu10001\"\n",
    "#        3.   vs   :\n",
    "stu_info_02 = dict(\n",
    "    stu10001 = \"alex\", \n",
    "    stu10002 = \"jack\",\n",
    "    stu10003 = \"marry\"\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "f6646fa8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'stu10001': 'alex', 'stu10002': 'jack', 'stu10003': 'marry'}"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stu_info_02"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a058df8e",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
